﻿#region Using region
using System;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Collections.Specialized;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;


using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Geometry;
using JigLibX.Math;
using JigLibX.Utils;
using sqengine.PhysicObjects;
using JigLibX.Vehicles;
using System.Diagnostics;



using sqengine.Engine;
using sqengine.Components;

using sqengine.Engine.Common;


using SqEngine.Components;
using SqEngine.Audio;
using SqEngine;

using PK3Model;
#endregion

namespace sqengine.Builder
{
    public class mapbuilder
    {

        #region Variables
        private AdvancedContent _adcontent;
        #endregion

        #region Constructor
        public mapbuilder(AdvancedContent adcontent)
        {
            this._adcontent = adcontent;
        }
        #endregion



        #region Helpers for Build maps

        public PresentationMessage AddPresentationMessage(string text, Color textcolor, Vector2 position, double lifetime, PresentationType animation, bool shadow, Color shadowcolor)
        {
            PresentationMessage _pm = new PresentationMessage();

            _pm.text = text;
            _pm.text_color = textcolor;
            _pm.position = position;
            _pm.lifetime = lifetime;
            _pm.animantion = animation;
            _pm.shadow = shadow;
            _pm.shadow_color = shadowcolor;

            return _pm;
        }

        public IntroContent AddIntroContent(List<PresentationMessage> msglist, string sng_background)
        {
            IntroContent _intro = new IntroContent();

            _intro.IntroText = msglist;
            _intro.BackgroundSong = sng_background;

            return _intro;
        }

        public BasicWorldObject AddBasicWorldObject(string Name, string fObject, string Texture)
        {
            BasicWorldObject _bwo = new BasicWorldObject();
            _bwo.Name = Name;
            _bwo.ObjectFilename = fObject;
            _bwo.Texture = Texture;

            return _bwo;
        }

        public WorldObject AddWorldObject(string BasicWorldObj, WorldObjectType type, float mass, Vector3 position, Vector3 rotation, float scale, HybridDictionary parameters)
        {
            WorldObject _wob = new WorldObject();

            _wob.BasicWorldObject = BasicWorldObj;
            _wob.ObjectType = type;
            _wob.Mass = mass;
            _wob.Position = position;
            _wob.Rotation = rotation;
            _wob.Scale = scale;

            if (parameters != null)
                _wob.Params = parameters;


            return _wob;
        }

        public BotInfo AddBotInfo(string modelname, string botname, float scale, WeaponInfo weapon, BotAudioInfo botaudio, BotMessagesInfo messages)
        {
            BotInfo _bot = new BotInfo();

            _bot.ModelName = modelname;
            _bot.Weapon = weapon;
            _bot.BotAudio = botaudio;
            _bot.Scale = Vector3.One * scale;
            _bot.BotMessages = messages;

            return _bot;
        }

        public WeaponInfo AddWeaponInfo(string name, string model, string model_texture, float scale, int damage, int max_ammo, Vector3 offset, string shot_audio, string no_ammo_audio )
        {
            WeaponInfo _wi = new WeaponInfo();
            _wi.WeaponName = name;
            _wi.WeaponModel = model;
            _wi.WeaponTexture = model_texture;
            _wi.Weapon_scale = scale;
            _wi.Weapon_x_off = offset.X;
            _wi.Weapon_y_off = offset.Y;
            _wi.Weapon_z_off = offset.Z;
            _wi.WeaponMaxAmmo = max_ammo;
            _wi.WeaponShootSound = shot_audio;
            _wi.WeaponOutOfAmmoSound = no_ammo_audio;
            _wi.WeaponDamage = damage;
            
            return _wi;

        }

        public BotAudioInfo AddBotAudio(string attacksound, string deadsound1, string deadsound2, string deadsound3, string jumpsound, string difensesound, string randomsound)
        {
            BotAudioInfo _ba = new BotAudioInfo();
            _ba.AttackSnd = attacksound;
            _ba.Dead1Snd = deadsound1;
            _ba.Dead2Snd = deadsound2;
            _ba.Dead3Snd = deadsound3;
            _ba.JumpSnd = jumpsound;
            _ba.DifenseSnd = difensesound;
            _ba.RandomSnd = randomsound;

            return _ba;
        }

        public MapObject AddMapObject(string name, string author, string description, List<WorldBot> botlist,List<WorldObject> objects , MapType type, Vector3 player_start, float skydome_time, string terrain_model, string terrain_texture)
        {
            MapObject _map = new MapObject();
            
            MapInfo _info = new MapInfo();
            _info.Author = author;
            _info.Description = description;
            _info.MapName = name;
            _info.BotsCount = botlist.Count;
            _info.ObjectsCount = objects.Count;

            _map.MapType = type;
            _map.PlayerStartPosition = player_start;
            _map.SkydomeTime = skydome_time;
            _map.TerrainModel = terrain_model;
            _map.TerrainTexture = terrain_texture;
            _map.Bots = botlist;
            _map.WorldObjects = objects;
            

            return _map;

        }

        #endregion
    }
}
